package com.treasure.mall.biz.entity.contact;

import com.treasure.mall.biz.entity.BasePO;
import com.treasure.mall.biz.entity.user.UserPO;
import com.treasure.mall.zbq.common.constant.Constant;
import com.treasure.mall.zbq.common.ienum.chat.ChatEnums;
import lombok.Data;

import javax.persistence.*;
import java.time.LocalDateTime;

/**
 *
 * <p> 聊天时
 * +---------------------------------------------------------
 * * @package: com.treasure.mall.biz.entity.contact
 * * @author: guomw (guomwchen@foxmail.com)
 * * @date: 2020/8/11 5:49 下午
 * * @since: V1.0.0
 * +---------------------------------------------------------
 * 注意：本内容仅限于内部传阅，禁止外泄以及用于其他的商业目的
 * 
 */
@Entity
@Data
@Table(name = "zb_chat_room")
public class ChatPO extends BasePO {


    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id")
    private Long id;

    /**
     * 回话类型
     * {@link com.treasure.mall.zbq.common.ienum.chat.ChatEnums.ChatType}
     */
    @Column(name = "chat_type")
    private ChatEnums.ChatType chatType;

    /**
     * 目标用户
     */
    @ManyToOne
    @JoinColumn(name = "rel_user_id", foreignKey = @ForeignKey(value = ConstraintMode.NO_CONSTRAINT))
    protected UserPO userPO;

    /**
     * 群组ID
     */
    @Column(name = "group_id", length = 50)
    private String groupId;
    /**
     * 群组名称
     */
    @Column(name = "group_name", length = 50)
    private String groupName;

    @Column(name = "logo", length = 200)
    private String logo;


    /**
     * 所属客服商户ID
     */
    @Column(name = "merchant_id")
    private Long merchantId;

    /**
     * 未读数量
     */
    @Column(name = "no_read_count")
    private Long noReadCount;


    /**
     * 用户未读数量
     */
    @Column(name = "user_no_read_count")
    private Long userNoReadCount;

    /**
     * 最后回复的消息内容
     */
    @Column(name = "last_reply_message", length = 200)
    private String lastReplyMessage;
    /**
     * 最后回复时间
     */
    @Column(name = "last_reply_time", columnDefinition = Constant.DATE_COLUMN_DEFINITION)
    private LocalDateTime lastReplyTime;


}
